/**
 * @author shenw
 */
function drawConsole() {
	blit(consoleImages['imgGameFrame'], 0, 0);
	blit(consoleImages['imgConsoleLeft'], 0, 240);
	blit(consoleImages['imgConsoleMiddle'], 108, 240);
	blit(consoleImages['imgConsoleRight'], 215, 240);
}

function updateLights() {
	gameState.lightChangeCounter++;
	if (gameState.lightChangeCounter > 12) {
		gameState.lightChangeCounter = 0;
		// hide the frame
		consoleImages['imgGameFrame'].style.display = "none";
		// draw mini-game area frame
		blit(consoleImages['imgGameFrame'], 0, 0);
		
		// fresh console light on or off randomly.
		for (var i=0; i<frameLights.length; i++) {
			if (jshen.math.randomInteger(0, 1) === 1) {
				blit(consoleImages[frameLights[i].name], frameLights[i].left, frameLights[i].top);
			} else {
				consoleImages[frameLights[i].name].style.display = "none";
			}
		}
	}
}

function updateHands() {
	consoleImages['imgLeftHandNormal'].style.display = "none";
	consoleImages['imgLeftHandUp'].style.display = "none";
	consoleImages['imgLeftHandDown'].style.display = "none";
	consoleImages['imgLeftHandLeft'].style.display = "none";
	consoleImages['imgLeftHandRight'].style.display = "none";
	consoleImages['imgLeftHandUL'].style.display = "none";
	consoleImages['imgLeftHandUR'].style.display = "none";
	consoleImages['imgLeftHandDL'].style.display = "none";
	consoleImages['imgLeftHandDR'].style.display = "none";
	consoleImages['imgRightHandDown'].style.display = "none";
	// fresh left hand
	var playerDirection = 0;
	if (gameState.playerDirectionUp) {
		playerDirection += 1;
	}
	if (gameState.playerDirectionRight) {
		playerDirection += 2;
	}
	if (gameState.playerDirectionDown) {
		playerDirection += 4;
	}
	if (gameState.playerDirectionLeft) {
		playerDirection += 8;
	}
	switch (playerDirection) {
		case 1:// up
			playerDirection = consoleImages['imgLeftHandUp'];
			break;
		case 2:// right
			playerDirection = consoleImages['imgLeftHandRight'];
			break;
		case 4:// down
			playerDirection = consoleImages['imgLeftHandDown'];
			break;
		case 8:// left
			playerDirection = consoleImages['imgLeftHandLeft'];
			break;
		case 3:// up & right
			playerDirection = consoleImages['imgLeftHandUR'];
			break;
		case 6:// down & right
			playerDirection = consoleImages['imgLeftHandDR'];
			break;
		case 12:// down & left
			playerDirection = consoleImages['imgLeftHandDL'];
			break;
		case 9:// up & left
			playerDirection = consoleImages['imgLeftHandUL'];
			break;
		default:
			playerDirection = consoleImages['imgLeftHandNormal'];
			break;
	}
	// fresh left hand
	blit(playerDirection, 29, 240);
	
	// fresh right hand
	if (gameState.playerAction) {
		blit(consoleImages['imgRightHandDown'], 145, 240);
	} else {
		blit(consoleImages['imgRightHandUp'], 145, 240);
	}
}
